package com.dto;

import com.bean.CodeEnum;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;


/**
 * @author FatterShadystart
 * @create 2023-01-18 1:31
 */
@Data
public class BaseMsg<T> {
    private Integer code;
    private String msg;
    private T data;

    public static BaseMsg succeess(){
        BaseMsg baseMsg=new BaseMsg();
        baseMsg.setMsg(CodeEnum.SUCCESS.getMsg());
        baseMsg.setCode(CodeEnum.SUCCESS.getErrorCode());
        return baseMsg;
    }

    public static BaseMsg fail(){
        BaseMsg baseMsg=new BaseMsg();
        baseMsg.setMsg(CodeEnum.FAILED.getMsg());
        baseMsg.setCode(CodeEnum.FAILED.getErrorCode());
        return baseMsg;
    }

    public  BaseMsg succeessBuildData(T data){
        BaseMsg baseMsg=new BaseMsg();
        baseMsg.setMsg(CodeEnum.SUCCESS.getMsg());
        baseMsg.setCode(CodeEnum.SUCCESS.getErrorCode());
        baseMsg.setData(data);
        return baseMsg;
    }
    public  BaseMsg failBuildData(T data){
        BaseMsg baseMsg=new BaseMsg();
        baseMsg.setMsg(CodeEnum.FAILED.getMsg());
        baseMsg.setCode(CodeEnum.FAILED.getErrorCode());
        baseMsg.setData(data);
        return baseMsg;
    }
}
